package com.anfeng.cms.controller;

import com.anfeng.cms.domain.org.AfJob;
import com.anfeng.cms.domain.org.AfPost;
import com.anfeng.cms.request.org.DepartDTO;
import com.anfeng.cms.service.org.IAfDepartmentService;
import com.anfeng.cms.service.org.IAfJobService;
import com.anfeng.cms.service.org.IAfPostService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;
import java.util.Map;

/**
 * @author 吴朋
 * @date 2019/7/22
 */
@Controller
@Slf4j
public class OrgController {

    @Autowired
    private IAfDepartmentService departmentService;
    @Autowired
    private IAfPostService postService;
    @Autowired
    private IAfJobService jobService;

    @GetMapping("org/dept/info")
    public String deptManager(Map<String, Object> objectMap) {
        List<DepartDTO> organizationTree = departmentService.getOrganizationTree();
        objectMap.put("datas", organizationTree);
        return "org/deptmanage";
    }

    @GetMapping("org/post/info")
    public String postManager(Map<String, Object> objectMap) {
        List<AfPost> allPosts = postService.getAllPosts();
        objectMap.put("datas", allPosts);
        return "org/postmanage";
    }

    @GetMapping("org/type/info")
    public String typeManager(Map<String, Object> objectMap) {
        List<AfJob> allJobs = jobService.getAllJobs();
        objectMap.put("datas", allJobs);
        return "org/typemanage";
    }
}
